package com.sunny.springboot2.core.annotation;

import com.sunny.springboot2.core.handler.DateTimeValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 日期校验 格式：yyyy-MM-dd HH:mm:ss
 * @author sunny
 * @date 2018/11/30
 */
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = DateTimeValidator.class)
public @interface DateTime {

    String message() default "格式错误";

    String format() default "yyyy-MM-dd HH:mm:ss";

    /**
     * groups 属性的作用就让 @Validated 注解只验证与自身 value 属性相匹配的字段，可多个，只要满足就会去纳入验证范围
     *
     * @author sunny
     * @date 2018/11/30
     * @return java.lang.Class<?>[]
     */
    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
